package br.com.passeionaweb.appengine.tabelafipe;

import java.io.IOException;
import java.util.List;

import javax.jdo.PersistenceManager;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.passeionaweb.appengine.tabelafipe.data.Make;
import br.com.passeionaweb.appengine.tabelafipe.data.Model;
import br.com.passeionaweb.appengine.tabelafipe.data.PMF;
import br.com.passeionaweb.appengine.tabelafipe.data.Version;
import br.com.passeionaweb.appengine.tabelafipe.data.Year;
import br.com.passeionaweb.appengine.tabelafipe.data.YearVersion;

public class ClearServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
	PersistenceManager pm = PMF.get().getPersistenceManager();
	pm.deletePersistentAll((List<Make>)pm.newQuery(Make.class).execute());
	pm.deletePersistentAll((List<Model>)pm.newQuery(Model.class).execute());
	pm.deletePersistentAll((List<Year>)pm.newQuery(Year.class).execute());
	pm.deletePersistentAll((List<Version>)pm.newQuery(Version.class).execute());
	pm.deletePersistentAll((List<YearVersion>)pm.newQuery(YearVersion.class).execute());
	resp.getWriter().write("true");
}
}
